package com.mszlu.blog.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mszlu.blog.dao.dos.Archives;
import com.mszlu.blog.dao.pojo.Article;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Package: com.mszlu.blog.dao.mapper
 * @ClassName: ArticleMapper
 * @Author: 陈威
 * @CreateTime: 2021/8/27 14:46
 * @Description:
 */

public interface ArticleMapper extends BaseMapper<Article> {

    List<Archives> listArchives();
    IPage<Article> listArticle(Page<Article> page,@Param("categoryId") Long categoryId,
                               @Param("tagId") Long tagId,
                               @Param("year")String year,
                               @Param("month")String month, @Param("nickname")String nickname/*, @Param("current") int current, @Param("pageSize") int pageSize*/);

    IPage<Article> listArticleAll(Page<Article> page,@Param("title")String title,@Param("author")String author);

    @Select("select * from ms_article where author_id in(select id from ms_sys_user where nickname like '%${nickname}%')")
    List<Article> listArticleByNickName(String nickname);

    //获取总评论量
    @Select("select sum(view_counts) FROM ms_article;\n")
    Long selectReadNum();

    void updateArticle(Article article);


    int selectTotalCount();

    Article selectByIdOne(Long id);
    /*int selectTotalCount();*/
}